param ([string]$Web = $(throw "Path to folder required."))

#$Web = "G:\Source\Jakkaj\TechEd\HooIzDat\Web" ;

$CombinedJsPath =  Join-Path -Path $Web -ChildPath "\Scripts\combined.js" ;
$CombinedDebugJsPath = $CombinedJsPath.Replace(".js", ".debug.js") ;

$CombinedJsPath ;

Remove-Item -Path $CombinedJsPath -ErrorAction SilentlyContinue ;
Remove-Item -Path $CombinedDebugJsPath -ErrorAction SilentlyContinue ;

$ScriptFilePaths = "~/Scripts/MicrosoftAjax.js", `
                   "~/Scripts/MicrosoftMvcAjax.js", `
                   "~/Scripts/jquery-1.3.2.js", `
                   "~/Scripts/jquery.css-transform.js", `
                   "~/Scripts/jquery.rotate3di-0.9.js", `
                   "~/Scripts/site.js" ;


ForEach ($path in $ScriptFilePaths) {
    $sourcePath = Join-Path $Web -ChildPath $path.Replace("~/", "\").Replace("/", "\") ;
    $debugSourcePath = $sourcePath.Replace(".js", ".debug.js") ;
    
    #$sourcePath ;
    #$debugSourcePath ;
    
    If (Test-Path $sourcePath) {
        $sourcePath ;
        Get-Content -Path $sourcePath |
            Add-Content -Path $CombinedJsPath -Encoding UTF8 ;
    }
    ElseIf (Test-Path $debugSourcePath) {
        $debugSourcePath ;
        Get-Content -Path $debugSourcePath |
            Add-Content -Path $CombinedJsPath -Encoding UTF8 ;
    }
    
    If (Test-Path $debugSourcePath) {
        $debugSourcePath ;
        Get-Content -Path $debugSourcePath |
            Add-Content -Path $CombinedDebugJsPath -Encoding UTF8 ;
    }
    ElseIf (Test-Path $sourcePath) {
        $sourcePath ;
        Get-Content -Path $sourcePath |
            Add-Content -Path $CombinedDebugJsPath -Encoding UTF8 ;
    }
    
}